<div class="new_contribution_form_wrapper">

  <%= form_for Contribution.new, :html => { :multipart => true, :id => form_id, :class => "new_contribution_document" }, :remote => false do |f| %>
    <% if !wa_assignment.nil?%>
      <%= f.hidden_field :wa_assignment_id, :value => wa_assignment.id %>
    <% elsif !parent.nil? %>
      <%= f.hidden_field :parent_id, :value => parent.id %>
    <% end %>
    <%= f.hidden_field :type, :value => "Document" %>
    <input class="contribution_file_input" name="document[file]" type="file">
    <%= f.submit t('document.upload'), :id=>"" ,:class => "contribution", :disabled => true %>
  <% end %>

  <button class="btn btn-primary btn_show_upload"><%= I18n.t('workshop.activities.assignment.available_contributions.document') %></button>
  <button class="btn btn-default btn_hidden_upload"><i class="fa fa-chevron-left"></i></button>

  <% content_for :javascript do %>
    <% unless editMode %>
        $("#"+'<%=form_id%>').parent().find(".btn_show_upload").click(function(){
          $("#" + '<%=form_id%>').show("slow");
          $(this).hide("slow");
          $(this).parent().find(".btn_hidden_upload").show("slow");
        });

        $("#"+'<%=form_id%>').parent().find(".btn_hidden_upload").click(function(){
          $("#" + '<%=form_id%>').hide("slow");
          $(this).hide("slow");
          $(this).parent().find(".btn_show_upload").show("slow");
        });

        $("#"+'<%=form_id%>').parent().find(".contribution_file_input").change(function(){
          var submitButton = $(this).parent().find("input[type='submit']");
          if($(this).val()!=""){
            $(submitButton).removeAttr("disabled");
          } else {
            $(submitButton).attr("disabled","disabled");
          }
        });
    <% end %>
  <% end %>
</div>